package com.uenpay.im.serializations;

import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONObject;

import com.qyx.android.entity.FriendEntity;

public class FriendSerializer {
	public static FriendEntity DeserializeFriend(JSONObject json) {
		FriendEntity friend = new FriendEntity();
		friend.cust_id = json.optString("custid");
		friend.nick_name = json.optString("nickname");
		friend.remarks_name = json.optString("_nickname");
		friend.real_name = json.optString("realname");
		friend.pinyin_name = json.optString("pinyinname");
		friend.sex = json.optInt("sex");
		friend.age = json.optInt("age");
		friend.birthday = json.optString("birthday");
		friend.mobile = json.optString("mobile");
		friend.email = json.optString("email");
		friend.idenum = json.optString("idenum");
//		JSONObject jsonObject = json.optJSONObject("msgsetting");
//		if(jsonObject != null){
//			int push = jsonObject.optInt("push");
//			if(push == 1){
//				friend.is_remind = 0;
//			}else{
//				friend.is_remind = 1;
//			}
//		}
		return friend;
	}

	public static ArrayList<FriendEntity> DeserializeFriends(JSONArray json) {
		ArrayList<FriendEntity> friends = new ArrayList<FriendEntity>();
		for (int i = 0; i < json.length(); i++) {
			friends.add(DeserializeFriend(json.optJSONObject(i)));
		}
		return friends;
	}
}